﻿<!--#include file="h.asp"--><%
'
'	七色虎建站系统
'	论坛帖子页面
'	2011.11.2

Sub main
	' 帖子及回帖配置
	If Not ifNum(numBbsHit) Then numBbsHit="0"'帖子点击种子
	If Not ifNum(numReplyMin) Then numReplyMin="0"'回帖最少字数
	If Not ifNum(numReplyMax) Then numReplyMax="200"'回帖最多字数
	If Not ifNum(wapAccess) Then wapAccess="0"'会员独享

	Dim id,p,act,tpl,body_,rs,sql,userIP,userid,classid,authorNormal
	Dim title,hit,edittime,staff,pid,author,ad5txt,content,savetime,source,admin,discuss,keep,input
	Dim count,i,content_,link_,weibo,sign,type_,fileId
	userid=user_array(0)
	If (wapAccess="2" Or wapAccess="5") And userid=0 Then rupt "错误","帖子仅会员独享,请"&hu.url("bbs_login.asp?_u="&back_url,"登录")&"查看"
	id=getN("id",1)
	p=getN("p",1)
	act=getData("act")
	tpl=ubbcode(tplPost)
	sql = "select t.userid,t.title,t.content,t.hit,t.savetime,t.edittime,t.type,t.pid,t.subtype,u.name,u.remark,c.name as class,u.status,c.classid,"&_
		"c.host from ((74hu_topic t inner join 74hu_user u on t.userid=u.id) inner join 74hu_bbs c on c.classid=t.classid) where t.id="&id
	Set rs=hu.conn(sql)
	If Not rs.eof Then
		title=rs("title")
		userIP=user_array(7)
		Call setVisitPage("<a href='"&http_path&"bbs_posts.asp?id="&id&"&amp;[sid]'>"&getLeft(title,8)&"</a>")
		keep = showImg("keep")&hu.url("bbs_keep.asp?a=1&amp;classid=3&amp;id="&id, "收藏这篇帖子")
		hit=1
		if numBbsHit>1 then
			hit=Int(Rnd*numBbsHit)+1
		end if
		hit=rs("hit")+hit
		classid=rs("classid")
		edittime=rs("edittime")
		author=rs("userid")
		authorNormal=ifStatusNormal(rs("status"))
		staff=rs("host")
		pid=rs("pid")
		sign=getUserRemark(rs("remark")&"")
		hu.conn("update 74hu_topic set hit="&hit&" where id="&id)
		hu.title = title
		body_ = checkMsg()'信息
		Call setUserAmount(userid, amtPosts)'加金币积分经验
		body_ = body_ & "[div=nav]-"&hu.url("?aid=index","首页")&"-"&hu.url("bbs_topic.asp?id="&classid, rs("class"))&"-帖子[/div]"
		ad5txt= getAD(5,1)
		content=rs("content")
		If authorNormal=False Then content = "用户信息被系统屏蔽"
		source= hu.url("bbs_user.asp?id="&author, rs("name"))
		savetime=fordate(rs("savetime"))
		type_=rs("type")'1普通精华帖,2文件帖,3图片贴,12文件精华帖,13图片精华帖
		content_ = left(content,200)'暂定200字
		weibo = Server.URLEncode(noUbbCode(left(content_, 140)))
		link_ = Server.URLEncode(http_path &"bbs_posts.asp?id="&id)
		weibo = "<a href='http://v.t.sina.com.cn/share/share.php?url="&link_&"&amp;title="&weibo&"'>"&showImg("xlwb")&"</a> "&_
		"<a href='http://v.t.qq.com/share/share.php?url="&link_&"&amp;title="&weibo&"'>"&showImg("qqwb")&"</a> "&_
		"<a href='http://sns.z.qq.com/share?url="&link_&"&amp;web_url="&link_&"&amp;title="&weibo&"'>"&showImg("qqkj")&"</a>"
		content=bbsUbb(content)
		If authorNormal=True And type_=2 Then
			fileId = rs("subtype")
			Set rs=hu.conn("select top 1 filesize,filetype,buy from 74hu_download where id="&fileId)
			If Not rs.eof Then
				content =content &"<br/>"&showImg("file")&""&hu.url("download.asp?id="&fileId,"下载(格式"&rs("filetype")&_
					"/大小"&forFileSize(rs("filesize"))&"/"&rs("buy")&""&bbsMoney&")")
			End If
		End If
		If edittime<>"" Then
			edittime=fordate(edittime)
		else
			edittime=""
		end if

		Dim isJingHua,noJingHua,okJingHua
		isJingHua = False
		Select Case type_
			Case 1
				noJingHua = 4
				isJingHua = True
			Case 12
				noJingHua = 42
				isJingHua = True
			Case 13
				noJingHua = 43
				isJingHua = True
			Case 0
				okJingHua = 3
			Case 2
				okJingHua = 32
			Case 3
				okJingHua = 33
			Case Else
				okJingHua = -1'避免出错
		End Select
		'精华帖不允许修改
		If isJingHua Then
			If staff=userid Then
				admin= "管理:"& hu.url("bbs_post.asp?id="&id&"&amp;a="&noJingHua,"取消加精")
				If pid=0 Then
					admin=admin& " "&hu.url("bbs_post.asp?id="&id&"&amp;a=5","置顶")
				Else
					admin=admin& " "&hu.url("bbs_post.asp?id="&id&"&amp;a=6","取消置顶")
				End If
			End If
			admin=admin& "<br/>"&showImg("jing")&"<font color=""red"">"&edittime&"加为精华帖</font>"
		Else
			If userid=author Or staff=userid Then admin="管理："&hu.url("bbs_post.asp?id="&id&"&amp;a=1","编辑")&_
				" "&hu.url("bbs_post.asp?id="&id&"&amp;a=2","删除")
			If staff=userid Then
				admin=admin& " "& hu.url("bbs_post.asp?id="&id&"&amp;a="&okJingHua,"加精")
				If pid=0 Then
					admin=admin& " "&hu.url("bbs_post.asp?id="&id&"&amp;a=5","置顶")
				Else
					admin=admin& " "&hu.url("bbs_post.asp?id="&id&"&amp;a=6","取消置顶")
				End If
			End If
		End If
		count = hu.conn("select count(id) from 74hu_reply where postid="&id)(0)'TODO 考虑换成帖子表中的回帖索引数
		sql = "select top 4 r.content,u.name from 74hu_reply r inner join 74hu_user u on r.userid=u.id where postid="&id&" order by r.id desc"
		Set rs= hu.conn(sql)
		If Not rs.eof Then
			For i=0 To 4
				If rs.eof Then Exit For
				discuss=discuss& (count - i)&"楼."&rs("name")&":"&replyUbb(getLeft(rs("content"),15))&"<br/>"
				rs.movenext
			Next
		End If
		Dim formarray(2)
		formarray(0) = http_path&"bbs_reply.asp?id="&id&"||post||回复"
		formarray(1) = "input||text$$$$20$$"&numReplyMax&"||<br/>"
		formarray(2) = "hidden||"&bbsSid&"$$"&sid&"||"
		discuss=discuss& "<a href="""&http_path&"bbs_replys.asp?id="&id&"&amp;"&sid_str&""">网友回复("&count&")</a>"
		input = hu.getForm(formarray) &	" (支持"&hu.url("bbs_reply.asp?a=-1","UBB")&")"
		If InStr(tpl,"{input}")=0 Then
			'兼容旧系统。并且帖子页肯定要有input
			discuss = discuss & "<br/>" & input
		End If
		Dim rndnum
		rndnum=time_r'要避免内容中有{}标签,需将{}转义
		tpl=Replace(tpl,"{","{_74hu_"&rndnum)
		tpl=Replace(tpl,"{_74hu_"&rndnum&"ad5}",ad5txt,1,1)
		tpl=Replace(tpl,"{_74hu_"&rndnum&"time}",savetime,1,1)
		tpl=Replace(tpl,"{_74hu_"&rndnum&"lasttime}",edittime,1,1)
		tpl=Replace(tpl,"{_74hu_"&rndnum&"hit}",hit,1,1)
		tpl=Replace(tpl,"{_74hu_"&rndnum&"source}",source,1,1)
		tpl=Replace(tpl,"{_74hu_"&rndnum&"sign}",sign,1,1)
		tpl=Replace(tpl,"{_74hu_"&rndnum&"admin}",admin,1,1)
		tpl=Replace(tpl,"{_74hu_"&rndnum&"title}",title,1,1)
		tpl=Replace(tpl,"{_74hu_"&rndnum&"content}",content,1,1)
		tpl=Replace(tpl,"{_74hu_"&rndnum&"discuss}",discuss,1,1)
		tpl=Replace(tpl,"{_74hu_"&rndnum&"input}",input,1,1)
		tpl=Replace(tpl,"{_74hu_"&rndnum&"weibo}",weibo,1,1)
		tpl=Replace(tpl,"{_74hu_"&rndnum&"keep}",keep,1,1)
		tpl=Replace(tpl,"<br/>修改：</div>","</div>",1,1)
		tpl=Replace(tpl,"修改：<br/>","",1,1)
		tpl=Replace(tpl,"</div><br/>","</div>")
		tpl=Replace(tpl,"<br/><br/>","<br/>")
		body_ = comUbb(body_ & tpl)
	Else
		rupt "出错！","没有这篇文章！"
	End If
	rs.close
	Set rs=Nothing
	hu.body = body_
End Sub

%>